//
//  RootViewController.m
//  MyToolBar
//
//  Created by wilson_chen on 2010/9/15.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "RootViewController.h"


@implementation RootViewController
@synthesize Scrollview;
@synthesize Tabbar;


#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
	[Scrollview setScrollEnabled:YES];
	//[Scrollview setContentSize:CGSizeMake(640.0, 50.0)];
	//[Scrollview setContentSize:CGSizeMake(Tabbar.frame.size.width, 50.0)];
	//self.view.autoresizesSubviews = YES;
	//self.view.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
	//Scrollview.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
}

/*
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}
*/

/*
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
	[super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
	[super viewDidDisappear:animated];
}
*/

 // Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	// Return YES for supported orientations.
	
	//return (interfaceOrientation == UIInterfaceOrientationPortrait);
	//printf("Orientation : %d\r\n", interfaceOrientation);
	
	/*
	switch (interfaceOrientation) {
		case UIInterfaceOrientationPortrait:
			Scrollview.frame = CGRectMake(0.0, 410.0, 320.0, 50.0);
			[Scrollview setContentSize:CGSizeMake(640.0, 50.0)];
			break;
		case UIInterfaceOrientationPortraitUpsideDown:
			Scrollview.frame = CGRectMake(0.0, 410.0, 320.0, 50.0);
			[Scrollview setContentSize:CGSizeMake(640.0, 50.0)];
			break;
		case UIInterfaceOrientationLandscapeLeft:
			Scrollview.frame = CGRectMake(0.0, 250.0, 480.0, 50.0);
			[Scrollview setContentSize:CGSizeMake(960.0, 50.0)];
			break;
		case UIInterfaceOrientationLandscapeRight:
			Scrollview.frame = CGRectMake(0.0, 250.0, 480.0, 50.0);
			[Scrollview setContentSize:CGSizeMake(960.0, 50.0)];
			break;			
		default:
			break;
	}
	*/
	
	printf("Tabbar's Width : %1.2f.\r\n", Tabbar.frame.size.width);
	if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
		self.view.frame = CGRectMake(0.0, 0.0, 320.0, 416.0);
		Scrollview.frame = CGRectMake(0.0, 366.0, 320.0, 50.0);
		//[Scrollview setContentSize:CGSizeMake(640.0, 50.0)];
		//[Scrollview setContentSize:CGSizeMake(Tabbar.frame.size.width, 50.0)];
	}
	else {
		self.view.frame = CGRectMake(0.0, 0.0, 480.0, 268.0);
		Scrollview.frame = CGRectMake(0.0, 218.0, 480.0, 50.0);
		//[Scrollview setContentSize:CGSizeMake(840.0, 50.0)];
		//printf("The Width : %1.2f.\r\n", (Tabbar.frame.size.width - 320.0));
		//[Scrollview setContentSize:CGSizeMake((self.view.frame.size.width + (Tabbar.frame.size.width - 320.0)), 50.0)];
	}
	[Scrollview setContentSize:CGSizeMake(Tabbar.frame.size.width, 50.0)];
	printf("View's Width : %1.2f.\r\n", self.view.frame.size.width);
	printf("View's Height : %1.2f.\r\n", self.view.frame.size.height);
	printf("ScrollerView's Width : %1.2f.\r\n", Scrollview.frame.size.width);
	printf("ScrollerView's content Width : %1.2f.\r\n", Scrollview.contentSize.width);
	return YES;
}


#pragma mark -
#pragma mark Table view data source

// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
	// Configure the cell.

    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/


/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source.
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
    }   
}
*/


/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/


/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/


#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
	/*
	 <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
	 [self.navigationController pushViewController:detailViewController animated:YES];
	 [detailViewController release];
	 */
}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Relinquish ownership any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end

